package cn.iocoder.yudao.module.biz.dal.mysql.emergencyMaterials;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.emergencyMaterials.vo.BizEmergencyMaterialsExportReqVO;
import cn.iocoder.yudao.module.biz.controller.admin.emergencyMaterials.vo.BizEmergencyMaterialsPageReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.emergencyMaterials.BizEmergencyMaterialsDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 应急物资 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizEmergencyMaterialsMapper extends BaseMapperX<BizEmergencyMaterialsDO> {

    default PageResult<BizEmergencyMaterialsDO> selectPage(BizEmergencyMaterialsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizEmergencyMaterialsDO>()
                .likeIfPresent(BizEmergencyMaterialsDO::getName, reqVO.getName())
//                .eqIfPresent(BizEmergencyMaterialsDO::getQuantity, reqVO.getQuantity())
//                .betweenIfPresent(BizEmergencyMaterialsDO::getProductionTime, reqVO.getBeginProductionTime(), reqVO.getEndProductionTime())
//                .betweenIfPresent(BizEmergencyMaterialsDO::getMaintenanceTime, reqVO.getBeginMaintenanceTime(), reqVO.getEndMaintenanceTime())
//                .betweenIfPresent(BizEmergencyMaterialsDO::getNextMaintenanceTime, reqVO.getBeginNextMaintenanceTime(), reqVO.getEndNextMaintenanceTime())
//                .betweenIfPresent(BizEmergencyMaterialsDO::getScrapTime, reqVO.getBeginScrapTime(), reqVO.getEndScrapTime())
                .likeIfPresent(BizEmergencyMaterialsDO::getChecker, reqVO.getChecker()));
//                .betweenIfPresent(BizEmergencyMaterialsDO::getCheckTime, reqVO.getBeginCheckTime(), reqVO.getEndCheckTime())
//                .eqIfPresent(BizEmergencyMaterialsDO::getStorageLocation, reqVO.getStorageLocation())
//                .eqIfPresent(BizEmergencyMaterialsDO::getRemark, reqVO.getRemark())
//                .eqIfPresent(BizEmergencyMaterialsDO::getAppendix, reqVO.getAppendix())
//                .betweenIfPresent(BizEmergencyMaterialsDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
//                .eqIfPresent(BizEmergencyMaterialsDO::getTenantId, reqVO.getTenantId())
//                .eqIfPresent(BizEmergencyMaterialsDO::getDeptId, reqVO.getDeptId()));
//                .orderByDesc(BizEmergencyMaterialsDO::getId));
    }

    default List<BizEmergencyMaterialsDO> selectList(BizEmergencyMaterialsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizEmergencyMaterialsDO>()
                .likeIfPresent(BizEmergencyMaterialsDO::getName, reqVO.getName())
                .eqIfPresent(BizEmergencyMaterialsDO::getQuantity, reqVO.getQuantity())
                .betweenIfPresent(BizEmergencyMaterialsDO::getProductionTime, reqVO.getBeginProductionTime(), reqVO.getEndProductionTime())
                .betweenIfPresent(BizEmergencyMaterialsDO::getMaintenanceTime, reqVO.getBeginMaintenanceTime(), reqVO.getEndMaintenanceTime())
                .betweenIfPresent(BizEmergencyMaterialsDO::getNextMaintenanceTime, reqVO.getBeginNextMaintenanceTime(), reqVO.getEndNextMaintenanceTime())
                .betweenIfPresent(BizEmergencyMaterialsDO::getScrapTime, reqVO.getBeginScrapTime(), reqVO.getEndScrapTime())
                .eqIfPresent(BizEmergencyMaterialsDO::getChecker, reqVO.getChecker())
                .betweenIfPresent(BizEmergencyMaterialsDO::getCheckTime, reqVO.getBeginCheckTime(), reqVO.getEndCheckTime())
                .eqIfPresent(BizEmergencyMaterialsDO::getStorageLocation, reqVO.getStorageLocation())
                .eqIfPresent(BizEmergencyMaterialsDO::getRemark, reqVO.getRemark())
                .eqIfPresent(BizEmergencyMaterialsDO::getAppendix, reqVO.getAppendix())
                .betweenIfPresent(BizEmergencyMaterialsDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
//                .eqIfPresent(BizEmergencyMaterialsDO::getTenantId, reqVO.getTenantId())
                .eqIfPresent(BizEmergencyMaterialsDO::getDeptId, reqVO.getDeptId())
                .orderByDesc(BizEmergencyMaterialsDO::getId));
    }

}
